package fun.stgoder.bmwf.gateway.config;

import fun.stgoder.bmwf.gateway.handler.GlobalExceptionHandler;
import fun.stgoder.bmwf.gateway.handler.SentinelFallbackHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

@Slf4j
@Configuration
public class GatewayConfig {

    @Bean
    @Order(-1)
    public GlobalExceptionHandler globalExceptionHandler() {
        return new GlobalExceptionHandler();
    }

    @Bean
    @Order(Ordered.HIGHEST_PRECEDENCE)
    public SentinelFallbackHandler sentinelGatewayExceptionHandler() {
        return new SentinelFallbackHandler();
    }
}
